package com.yyang.pai.di.module;

import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.di.scope.FragmentScope;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

import com.tbruyelle.rxpermissions2.RxPermissions;
import com.yyang.pai.mvp.contract.HomesContract;
import com.yyang.pai.mvp.model.HomesModel;
import com.yyang.pai.mvp.model.entity.Item;
import com.yyang.pai.mvp.ui.adapter.ItemAdapter;

import java.util.ArrayList;
import java.util.List;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 03/18/2019 11:40
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@Module
public abstract class HomesModule {

    @Binds
    abstract HomesContract.Model bindHomesModel(HomesModel model);

    @FragmentScope
    @Provides
    static RxPermissions provideRxPermissions(HomesContract.View view) {
        RxPermissions rxPermissions = new RxPermissions((FragmentActivity) view.vGetActivity());
        return new RxPermissions((FragmentActivity) view.vGetActivity());

    }

    @FragmentScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManager(HomesContract.View view) {
        return new GridLayoutManager(view.vGetActivity(), 2);
    }

    @FragmentScope
    @Provides
    static List<Item> provideUserList() {
        return new ArrayList<>();
    }

    @FragmentScope
    @Provides
    static RecyclerView.Adapter provideUserAdapter(List<Item> list){
        return new ItemAdapter(list);
    }
}